package com.kolakcc.loljclient.view.ui;

import java.awt.Font;

import javax.swing.ImageIcon;

import com.kolakcc.loljclient.model.Item;
import com.kolakcc.loljclient.model.RiotRecommendedItem;

public class ItemImageLabel extends javax.swing.JLabel {
	protected Item item;
	protected ImageIcon icon;

	public ItemImageLabel() {
		super();
		Font currentFont = this.getFont();
		this.setFont(new Font(currentFont.getName(),Font.PLAIN, (int) (currentFont.getSize() * 0.7)));
		this.setText("Loading..");
	}

	public ItemImageLabel(Item item) {
		super();
		this.item = item;
		this.initItemImageLabel();
	}

	public ItemImageLabel(RiotRecommendedItem recommendedItem) {
		super();
		this.item = Item.getItem(recommendedItem);
		this.initItemImageLabel();
	}

	protected void initItemImageLabel() {
		this.setOpaque(true);
		// this.setBackground(Color.BLACK); //Doesn't work, Java doesn't want to put black pixels behind the transparent pixels of the icon
		try {
			this.icon = new ImageIcon(this.item.getIcon());
			this.setIcon(this.icon);
		} catch (Exception e) {
			System.out.println("Could not find image for "
					+ this.item.getName());
			e.printStackTrace();
		}
	}
}
